<html>
<head><meta charset="utf-8"><title>conflicting lints · clippy · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/index.html">clippy</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/conflicting.20lints.html">conflicting lints</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="214493184"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/conflicting%20lints/near/214493184" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eduardo Broto <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/conflicting.20lints.html#214493184">(Oct 25 2020 at 14:48)</a>:</h4>
<p>It is my understanding that when two lints would trigger for the same span, we want to give one of them priority to avoid giving misleading or possibly contradicting suggestions (+ rustfix would not work for one of them).</p>
<p>If we have the guarantee that the lint with priority has been triggered, then it's OK. But if we only assume the other lint would trigger, what if that other lint is manually disabled? Do we have a solution for this case?</p>



<a name="214493704"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/conflicting%20lints/near/214493704" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/conflicting.20lints.html#214493704">(Oct 25 2020 at 15:00)</a>:</h4>
<p>Nope, not yet. I don't think rustc was designed with conflicting lints in mind. So all of our hacks (<code>if !lint_a() { lint_b() }</code>) have this problem. To properly fix this, we would need some query in rustc <code>lint_triggered_for_span(LINT_NAME, span)</code>. This would probably live in diagnostics, so you may want to ask in the <code>t-compiler/wg-diagnostics</code> stream, if they think that this would be possible (or even does already exist).</p>



<a name="214494163"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/conflicting%20lints/near/214494163" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eduardo Broto <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/conflicting.20lints.html#214494163">(Oct 25 2020 at 15:09)</a>:</h4>
<p>That would be nice to have, indeed. I will take a look at rustc before asking. </p>
<p>If that was not possible for some reason, we could even work out a solution in Clippy as we always use <code>span_lint_and_*</code>, but we would require to have shared state somehow.</p>
<p>Thanks for the answer!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>